import ch.swissdotnet.extdirect4j.AnnotatedAction;
import ch.swissdotnet.extdirect4j.ExtDirectRouter;
import ch.swissdotnet.extdirect4j.ExtRemoteAction;
import ch.swissdotnet.extdirect4j.ExtRemoteMethod;
import ch.swissdotnet.extdirect4j.NamedAction;
import java.io.PrintStream;

public class MyExtDirectRouter extends ExtDirectRouter
{
  protected void configureActions()
  {
    addAction(new AnnotatedAction(MyExtDirectRouter.TestAction.class));

    addAction(new AnnotatedAction("com.test.ExtdirectServlet$TestAction"));

    addAction(
      new NamedAction("com.test.ExtdirectServlet$TestAction").addMethod("multy", 1)
      .addMethod("multy", 2));
  }

  public static class Result
  {
    private Long result;
    private String msg;

    public Result(Long result, String msg)
    {
      this.result = result;
      this.msg = msg;
    }
  }

  public static abstract class AbstractAction {
    abstract Long multy(long paramLong1, long paramLong2);

    @ExtRemoteMethod(name="multy1")
    public Long multy(int a, long b) {
      return Long.valueOf(-a * b);
    }
  }

  @ExtRemoteAction(name="Action", lazyInit=true)
  public static class TestAction extends MyExtDirectRouter.AbstractAction {
    @ExtRemoteMethod
    public Long multy(long a, long b) {
      return Long.valueOf(a * b);
    }

    @ExtRemoteMethod(name="multy2")
    public Long multy(int a, long b) {
      return Long.valueOf(a * b);
    }

    @ExtRemoteMethod
    public MyExtDirectRouter.Result multy(long a) {
      return new MyExtDirectRouter.Result(Long.valueOf(a * 2L), "just a result");
    }

    @ExtRemoteMethod
    public String sayHello(String value) {
      return "Hello, " + value;
    }

    @ExtRemoteMethod
    public String getTree(String value) {
      System.out.println("被调到了");
      return "[{'id':10,'leaf':false,'children':[{'id':11,'leaf':true,'children':null,'text':'S600'},{'id':12,'leaf':true,'children':null,'text':'SLK200'}],'text':'Benz'}]";
    }
  }
}